package org.ghost.parallel.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SynchronizedTest {
    private final Logger logger = LoggerFactory.getLogger(SynchronizedTest.class);

    private int sum = 0;

    public synchronized void addSync(int val) {
        sum += val;
        logger.info("*****sum={}", sum);
    }

    public void add(int val) {
        sum += val;
        logger.info("*****sum={}", sum);
    }

    public void printSum() {
        logger.info("*****final result:{}", sum);
    }

}


